#!/bin/bash

# 提示用户输入容器名
echo -n "请输入容器名: "
read container_name

# 提示用户输入复制的目标路径
echo -n "请输入复制的目标路径: "
read target_path

# 完整的目标路径
full_target_path="$target_path/$container_name"

# 检查目标路径是否存在，如果不存在则创建
if [ ! -d "$full_target_path" ]; then
  mkdir -p "$full_target_path"
  echo "创建目录: $full_target_path"
fi

# 复制当前文件夹下的所有文件和文件夹到目标路径
cp -r ./* "$full_target_path"
chmod -R 7777 "$full_target_path"
# 修改 docker-compose.yml 文件中的 container_name
sed -i "s/container_name: .*/container_name: $container_name/" "$full_target_path/docker-compose.yml"

echo "复制完成，等待docker-compose启动"

cd "$full_target_path"

docker-compose -f "$full_target_path/docker-compose.yml" up -d
